package com.dotnet.modules.product.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;


import com.dotnet.common.web.BaseController;
import com.dotnet.modules.product.entity.ProductInfo;
import com.dotnet.modules.product.service.ProductInfoService;


@Controller
@RequestMapping(value="/web/productinfo")
public class ProductInfoController extends BaseController{
	
	@Autowired
	private ProductInfoService productInfoService;
	/**
	 * 
	 * 描述：首页展示
	 * 创建人： 高磊
	 * 创建时间: 2016-6-16 上午11:03:25
	 * @version
	 */
	@RequestMapping(value="/indexShow")
	public String indexShow(ModelMap model){
		ProductInfo productInfo = new ProductInfo();
		productInfo.setIsUse(1);
		productInfo.setIsDelete(0);
		productInfo.setIsUseIndex(1);
		List<ProductInfo> queryAll = productInfoService.queryAll(productInfo);
		model.put("list", queryAll);
		return "/productinfo/indexshow";
		
	}
	/**
	 * 
	 * 描述：查看详情
	 * 创建人： 高磊
	 * 创建时间: 2016-6-17 上午9:11:25
	 * @version
	 */
	@RequestMapping(value="/productDetail")
	public String productDetail(ModelMap model,ProductInfo productInfo){
		ProductInfo proInfo = new ProductInfo();
		proInfo.setIsUse(1);
		proInfo.setIsDelete(0);
		proInfo.setIsUseIndex(1);
		List<ProductInfo> queryAll = productInfoService.queryAll(proInfo);
		if(null!=queryAll && queryAll.size()>0){
			model.put("list", queryAll);
		}
		ProductInfo queryOne = productInfoService.queryOne(productInfo);
		if(null!=queryOne){
			model.put("pro", queryOne);
		}
		model.put("id", productInfo.getId());
		return "/productinfo/detail";
	}
	/**
	 * 
	 * 描述：产品中心展示
	 * 创建人： 高磊
	 * 创建时间: 2016-6-16 下午2:25:26
	 * @version
	 */
	@RequestMapping(value="/productShow")
	public String centerShow(ModelMap model,HttpServletRequest request){
		String cityName= (String) request.getSession().getAttribute("cityName");
		ProductInfo productInfo = new ProductInfo();
		productInfo.setIsUse(1);
		productInfo.setIsDelete(0);
		productInfo.setIsUseCenter(1);
		if(null!=cityName){
			productInfo.setCityName(cityName);
		}else{
			productInfo.setCityName("北京");
		}
		List<ProductInfo> queryAll = productInfoService.queryAll(productInfo);
		if(null!=queryAll && queryAll.size()>0){
			model.put("list", queryAll);
		}
		return "/productinfo/productshow";
		
	}
	
}
